/*** 
 * @Author: fuhongliang-TSJ hongliang.fu@4d-bios.com
 * @Date: 2025-08-19 16:09:52
 * @LastEditTime: 2025-10-10 11:01:49
 * @LastEditors: fuhongliang-TSJ hongliang.fu@4d-bios.com
 * @Description: 
 * @FilePath: \lc_-esp32_-s3\components\bsp\qmi8658\qmi8658.h
 * @立创实战派ESP32-S3开发板
 * @Copyright (c) 2025 by 4D Bios, All Rights Reserved. 
 */
#ifndef __QMI8658_H_
#define __QMI8658_H_

#include "iic.h"
#include "driver/gpio.h"

/* 相关参数定义 */
#define QMI8658_ADDR    0X6A                                        /* AP3216C地址 */

enum qmi8658_reg
{
    QMI8658_WHO_AM_I,
    QMI8658_REVISION_ID,
    QMI8658_CTRL1,
    QMI8658_CTRL2,
    QMI8658_CTRL3,
    QMI8658_CTRL4,
    QMI8658_CTRL5,
    QMI8658_CTRL6,
    QMI8658_CTRL7,
    QMI8658_CTRL8,
    QMI8658_CTRL9,
    QMI8658_CATL1_L,
    QMI8658_CATL1_H,
    QMI8658_CATL2_L,
    QMI8658_CATL2_H,
    QMI8658_CATL3_L,
    QMI8658_CATL3_H,
    QMI8658_CATL4_L,
    QMI8658_CATL4_H,
    QMI8658_FIFO_WTM_TH,
    QMI8658_FIFO_CTRL,
    QMI8658_FIFO_SMPL_CNT,
    QMI8658_FIFO_STATUS,
    QMI8658_FIFO_DATA,
    QMI8658_I2CM_STATUS = 44,
    QMI8658_STATUSINT,
    QMI8658_STATUS0,
    QMI8658_STATUS1,
    QMI8658_TIMESTAMP_LOW,
    QMI8658_TIMESTAMP_MID,
    QMI8658_TIMESTAMP_HIGH,
    QMI8658_TEMP_L,
    QMI8658_TEMP_H,
    QMI8658_AX_L,
    QMI8658_AX_H,
    QMI8658_AY_L,
    QMI8658_AY_H,
    QMI8658_AZ_L,
    QMI8658_AZ_H,
    QMI8658_GX_L,
    QMI8658_GX_H,
    QMI8658_GY_L,
    QMI8658_GY_H,
    QMI8658_GZ_L,
    QMI8658_GZ_H,
    QMI8658_MX_L,
    QMI8658_MX_H,
    QMI8658_MY_L,
    QMI8658_MY_H,
    QMI8658_MZ_L,
    QMI8658_MZ_H,
    QMI8658_dQW_L = 73,
    QMI8658_dQW_H,
    QMI8658_dQX_L,
    QMI8658_dQX_H,
    QMI8658_dQY_L,
    QMI8658_dQY_H,
    QMI8658_dQZ_L,
    QMI8658_dQZ_H,
    QMI8658_dVX_L,
    QMI8658_dVX_H,
    QMI8658_dVY_L,
    QMI8658_dVY_H,
    QMI8658_dVZ_L,
    QMI8658_dVZ_H,
    QMI8658_AE_REG1,
    QMI8658_AE_REG2,
    QMI8658_RESET = 96
};

typedef struct{
    int16_t acc_y;
    int16_t acc_x;
    int16_t acc_z;
    int16_t gyr_y;
    int16_t gyr_x;
    int16_t gyr_z;
    float AngleX;
    float AngleY;
    float AngleZ;
}qmi8658_t;

/* 函数声明 */
void qmi8658_init(i2c_obj_t self);                                  /* 初始化QMI8658 */
void qmi8658_fetch_angleFromAcc(qmi8658_t *p);                      /* 读取QMI8658倾角值 */
void qmi8658_close(void);                                           // 关闭芯片运行
uint8_t qmi8658_fetch_motion(void);                                 // 获取Motion状态
#endif
